document.addEventListener('DOMContentLoaded', function() {
    const volumeSlider = document.getElementById('volume');
    const speedSlider = document.getElementById('speed');

    const volumeValue = document.getElementById('volumeValue');

    // 更新显示的初始值
    volumeValue.textContent = volumeSlider.value * 100 + "%";

    function updateAudio(type, value) {
        chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
            chrome.tabs.sendMessage(tabs[0].id, {action: type, value: value});
        });
    }

    volumeSlider.addEventListener('input', function() {
        volumeValue.textContent = volumeSlider.value * 100 + "%";
        updateAudio('volume', this.value);
    });

    speedSlider.addEventListener('input', function() {
        updateAudio('speed', this.value);
    });
});
